<template>
  <div>
    <van-tabbar fixed route placeholder safe-area-inset-bottom v-model="active" active-color="#5881db" inactive-color="#000" @change="handleChange" :border="false">
      <van-tabbar-item v-for="(item, index) in data" :to="item.path" :key="index">
        <template #icon="props">
          <img :src="props.active ? item.activebg : item.inactivebg" />
        </template>
        {{ item.title }}
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  name: 'TabBar',
  props: {
    defaultActive: {
      type: Number,
      default: 0
    },
    data: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      active: this.defaultActive
    }
  },
  methods: {
    handleChange(value) {
      this.$emit('change', value)
    }
  }
}
</script>

<style scoped></style>
